package br.com.lazyprogrammer.worldsoccermanager;

import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.Window;
import android.view.WindowManager;

import br.com.lazyprogrammer.worldsoccermanager.fragments.adapter.CreateTeamAdapter;
import br.com.lazyprogrammer.worldsoccermanager.fragments.interfaces.OnNextListener;

/**
 * Created by Andre on 08/09/2014.
 */
public class CreateTeamActivity extends FragmentActivity implements OnNextListener {

    private CreateTeamAdapter adapter;

    @Override
    public void goToNext(int step) {
        openFragment(adapter.getItem(step));
    }

    @Override
    public void onBackPressed() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_ACTION_BAR);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        setTitle(R.string.title_create_team);

        setContentView(R.layout.activity_create_team);
        adapter = new CreateTeamAdapter(getSupportFragmentManager());
        openFragment(adapter.getItem(0));
    }

    private void openFragment(Fragment fragment) {
        FragmentManager fm = getSupportFragmentManager();
        FragmentTransaction ft;
        ft = fm.beginTransaction();
        ft.setTransition(FragmentTransaction.TRANSIT_NONE);
        ft.replace(R.id.layout_main, fragment);
        ft.commit();
    }

}
